﻿
using System.IO;
using System;
namespace Aristov.Picofday
{
    class Program
    {
        static void Main(string[] args)
        {
            string directoryPath = string.Empty;
            // arguments:
            // -d directory where to place images
            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];
                if (string.Equals(arg, "-d") || string.Equals(arg, "/d"))
                {
                    i++;
                    directoryPath = args[i];
                    continue;
                }
                if (string.Equals(arg, "-?") || string.Equals(arg, "/?"))
                {
                    Console.WriteLine("Usage:\nPicOfDay.exe [-d DirectoryPath]");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            BingPictureProvider bingPictureProvider = new BingPictureProvider();
            bingPictureProvider.SavePictures(directoryPath);

            NasaPictureProvider nasaPictureProvider = new NasaPictureProvider();
            nasaPictureProvider.SavePictures(directoryPath);
        }
    }
}
